package view.user;

import javax.swing.JPanel;
import javax.swing.JLabel;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import javax.swing.ButtonGroup;
import javax.swing.JComboBox;
import javax.swing.JButton;
import controller.ActionEvents.ActionHandler;
import javax.swing.JRadioButton;
import javax.swing.JTextField;

/**
 * @author Christian
 *Represents the Deposit panel using CardLayout*/

public class Deposit extends JPanel {
	
	private final ButtonGroup buttonGroup = new ButtonGroup();
	
	/** double amount that is to be deposited */
	private double depositAmount;
	
	/** synchronization object */
	private JLabel lblDeposit;
	private ActionHandler actionHandler;
	private JRadioButton rdbtnGoesGreenCoffee;
	private JRadioButton rdbtnLargeCoffee;
	private JRadioButton rdbtnGoesGreenFixie;
	private JRadioButton rdbtnCoffeeMug;
	private JComboBox comboBox;
	private JButton btnSubmit;
	private JComboBox comboBoxUsersCategories;
	private JTextField txtNewCategoryName;
	private JButton btnSubmitNewCategory;
	private JTextField txtCategoryAmount;
	private JLabel lblNewCategoryDefinition;
	private JLabel lblAmount;
	private JRadioButton rdbtnCustom;
	

	/**
	 * Creates the panel. 
	 * It allow the user to deposit an fixed amount of CC. */
	public Deposit(ActionHandler actionHandler) 
	{
		setLayout(null);
		this.actionHandler = actionHandler;
		setPreferredSize(new Dimension(750, 372));
		setBackground(Color.WHITE);
		
		lblDeposit = new JLabel("Deposit");
		lblDeposit.setFont(new Font("Euphemia UCAS", Font.PLAIN, 28));
		lblDeposit.setBounds(321, 6, 163, 39);
		add(lblDeposit);

		btnSubmit = new JButton();
		btnSubmit.addActionListener(actionHandler);
		btnSubmit.setActionCommand("depositSUBMIT");
		btnSubmit.setBounds(46, 311, 89, 23);
		btnSubmit.setBorderPainted(false);
		btnSubmit.setContentAreaFilled(false);
		add(btnSubmit);
		
		rdbtnGoesGreenCoffee = new JRadioButton("Small coffee");
		rdbtnGoesGreenCoffee.setBounds(6, 118, 220, 32);
		buttonGroup.add(rdbtnGoesGreenCoffee);
		rdbtnGoesGreenCoffee.setActionCommand("SMALLCOFFEE");
		add(rdbtnGoesGreenCoffee);
		
		rdbtnLargeCoffee = new JRadioButton("Large coffee");
		rdbtnLargeCoffee.setBounds(6, 147, 188, 32);
		buttonGroup.add(rdbtnLargeCoffee);
		rdbtnLargeCoffee.setActionCommand("LARGECOFFEE");
		add(rdbtnLargeCoffee);
		
		rdbtnGoesGreenFixie = new JRadioButton("Goes Green fixie bike");
		rdbtnGoesGreenFixie.setBounds(6, 205, 208, 32);
		buttonGroup.add(rdbtnGoesGreenFixie);
		rdbtnGoesGreenFixie.setActionCommand("FIXIEBIKE");
		add(rdbtnGoesGreenFixie);
		rdbtnCoffeeMug = new JRadioButton("Goes Green Coffee mug");
		rdbtnCoffeeMug.setActionCommand("STAIRWAY");
		rdbtnCoffeeMug.setBounds(6, 176, 188, 32);
		buttonGroup.add(rdbtnCoffeeMug);
		add(rdbtnCoffeeMug);
		
		comboBox = new JComboBox();
		comboBox.setBounds(6, 269, 250, 23);
		add(comboBox);
		
		comboBoxUsersCategories = new JComboBox();
		comboBoxUsersCategories.setBounds(40, 239, 216, 27);
		add(comboBoxUsersCategories);
		
		txtNewCategoryName = new JTextField();
		txtNewCategoryName.setBounds(452, 121, 246, 27);
		add(txtNewCategoryName);
		txtNewCategoryName.setColumns(10);
		
		btnSubmitNewCategory = new JButton("");
		btnSubmitNewCategory.setActionCommand("newDepositCategorySubmit");
		btnSubmitNewCategory.addActionListener(actionHandler);
		btnSubmitNewCategory.setBounds(609, 187, 89, 23);
		btnSubmitNewCategory.setBorderPainted(false);
		btnSubmitNewCategory.setContentAreaFilled(false);
		add(btnSubmitNewCategory);
		
		txtCategoryAmount = new JTextField();
		txtCategoryAmount.setBounds(584, 148, 114, 27);
		add(txtCategoryAmount);
		txtCategoryAmount.setColumns(10);
		
		lblNewCategoryDefinition = new JLabel("New category definition");
		lblNewCategoryDefinition.setBounds(290, 127, 150, 16);
		add(lblNewCategoryDefinition);
		
		lblAmount = new JLabel("Amount");
		lblAmount.setBounds(511, 154, 61, 16);
		add(lblAmount);
		
		rdbtnCustom = new JRadioButton("");
		rdbtnCustom.setBounds(6, 239, 33, 23);
		buttonGroup.add(rdbtnCustom);
		add(rdbtnCustom);

	}
	
	/**
	 * @return the btnSubmit
	 */
	public JButton getBtnSubmit() {
		return btnSubmit;
	}
	
	/**
	 * @return the comboBoxUsersCategories
	 */
	public JComboBox getComboBoxUsersCategories() {
		return comboBoxUsersCategories;
	}
	/**
	 * @param comboBoxUsersCategories the comboBoxUsersCategories to set
	 */
	public void setComboBoxUsersCategories(JComboBox comboBoxUsersCategories) {
		this.comboBoxUsersCategories = comboBoxUsersCategories;
	}
	/**
	 * @return the depositAmount
	 */
	public double getDepositAmount() {
		return depositAmount;
	}
	/**
	 * @return the txtNewCategoryName
	 */
	public JTextField getTxtNewCategoryName() {
		return txtNewCategoryName;
	}
	/**
	 * @return the txtCategoryAmount
	 */
	public JTextField getTxtCategoryAmount() {
		return txtCategoryAmount;
	}
	/**
	 * @return the comboBox
	 */
	public JComboBox getComboBox() {
		return comboBox;
	}
	/**
	 * @param comboBox the comboBox to set
	 */
	public void setComboBox(JComboBox comboBox) {
		this.comboBox = comboBox;
	}
	/**
	 * @return the rdbtnGoesGreenCoffee
	 */
	public JRadioButton getRdbtnGoesGreenCoffee() {
		return rdbtnGoesGreenCoffee;
	}
	/**
	 * @return the rdbtnLargeCoffee
	 */
	public JRadioButton getRdbtnLargeCoffee() {
		return rdbtnLargeCoffee;
	}
	/**
	 * @return the rdbtnGoesGreenFixie
	 */
	public JRadioButton getRdbtnGoesGreenFixie() {
		return rdbtnGoesGreenFixie;
	}
	/**
	 * @return the rdbtnCoffeeMug
	 */
	public JRadioButton getRdbtnCoffeeMug() {
		return rdbtnCoffeeMug;
	}

	/**
	 * @return the rdbtnCustom
	 */
	public JRadioButton getRdbtnCustom() {
		return rdbtnCustom;
	}

	/**
	 * @return the btnSubmitNewCategory
	 */
	public JButton getBtnSubmitNewCategory() {
		return btnSubmitNewCategory;
	}
}
